Telegram Group & Telegram Channel
اسکریپت Lua برای ارتباط nodemcu و oled


sda = 2 — SDA Pin
scl = 1 — SCL Pin

s=0
m=0
h=0

function init_OLED(sda,scl) —Set up the u8glib lib
sla = 0x3C
i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g.ssd1306_128x64_i2c(sla)
disp:setFont(u8g.font_6x10)
disp:setFontRefHeightExtendedText()
disp:setDefaultForegroundColor()
disp:setFontPosTop()
—disp:setRot180() — Rotate Display if needed
end

function write_OLED() — Write Display
disp:firstPage()
repeat
disp:drawStr(50, 10, "Timer")
disp:drawStr(40, 30, string.format("%02d:%02d:%02d",h,m,s))
disp:drawStr(20, 50, "hello")
until disp:nextPage() == false
end

— Main Program
init_OLED(sda,scl)

tmr.alarm(0, 1000, 1, function() — Every second increment clock and display
s = s+1
if s==60 then
s=0
m=m + 1
end
if m==60 then
m=0
h=h + 1
end
if h==13 then
h=1
end
write_OLED()
end)



tg-me.com/micropython_iot/63
Create:
Last Update:

اسکریپت Lua برای ارتباط nodemcu و oled


sda = 2 — SDA Pin
scl = 1 — SCL Pin

s=0
m=0
h=0

function init_OLED(sda,scl) —Set up the u8glib lib
sla = 0x3C
i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g.ssd1306_128x64_i2c(sla)
disp:setFont(u8g.font_6x10)
disp:setFontRefHeightExtendedText()
disp:setDefaultForegroundColor()
disp:setFontPosTop()
—disp:setRot180() — Rotate Display if needed
end

function write_OLED() — Write Display
disp:firstPage()
repeat
disp:drawStr(50, 10, "Timer")
disp:drawStr(40, 30, string.format("%02d:%02d:%02d",h,m,s))
disp:drawStr(20, 50, "hello")
until disp:nextPage() == false
end

— Main Program
init_OLED(sda,scl)

tmr.alarm(0, 1000, 1, function() — Every second increment clock and display
s = s+1
if s==60 then
s=0
m=m + 1
end
if m==60 then
m=0
h=h + 1
end
if h==13 then
h=1
end
write_OLED()
end)

BY Micropython & IOT


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/micropython_iot/63

View MORE
Open in Telegram


Micropython & IOT Telegram | DID YOU KNOW?

Date: |

Traders also expressed uncertainty about the situation with China Evergrande, as the indebted property company has not provided clarification about a key interest payment.In economic news, the Commerce Department reported an unexpected increase in U.S. new home sales in August.Crude oil prices climbed Friday and front-month WTI oil futures contracts saw gains for a fifth straight week amid tighter supplies. West Texas Intermediate Crude oil futures for November rose $0.68 or 0.9 percent at 73.98 a barrel. WTI Crude futures gained 2.8 percent for the week.

The seemingly negative pandemic effects and resource/product shortages are encouraging and allowing organizations to innovate and change.The news of cash-rich organizations getting ready for the post-Covid growth economy is a sign of more than capital spending plans. Cash provides a cushion for risk-taking and a tool for growth.

Micropython & IOT from kr


Telegram Micropython & IOT
FROM USA